<template>
  <div>
    <el-table :data="initData">
      <el-table-column prop="opt_id" hidden label="操作id" width="120">
      </el-table-column>
      <el-table-column prop="opt_module" label="操作模块" width="160">
      </el-table-column>
      <el-table-column prop="opt_content" label="操作内容" width="360">
      </el-table-column>
      <el-table-column prop="opt_time" label="操作时间" width="260">
      </el-table-column>
      <el-table-column prop="remark" label="备注">
      </el-table-column>
    </el-table>
    <el-pagination
      :current-page="pageNo"
      :page-size="pageSize"
      :total="total"
      style="padding: 30px 0; text-align: right;"
      layout="total, prev, pager, next, jumper"
      @current-change="getPageList"
    />
  </div>
</template>

<script>
import opt_record from '@/api/opt_record';
export default {
    name:'OptRecordList',
    props:['opt_id', 'opt_module'],
    data(){
        return {
            pageNo:1,
            pageSize:20,
            total:0,
            initData: [],
            optId:this.$props.opt_id,
            optModule:this.$props.opt_module
        }
    },
    methods:{
        initOptRecordData(){
            let queryOptRecordDto = {
                pageNo:1,
                pageSize:this.pageSize,
                optId:this.optId,
                optModule:this.optModule
            }
            opt_record.getOptRecordList(queryOptRecordDto).then(
                response => {
                    console.log('操作记录响应数据：', response)
                    let resCode = response.data.code
                    let resMsg = response.data.message
                    if(resCode == "200") {
                        this.initData = response.data.data.data_list
                        this.pageNo = response.data.data.page_no
                        this.pageSize = response.data.data.page_size
                        this.total = response.data.data.total
                    } else {
                        //异常提示
                        this.$message({
                            type: 'error',
                            message: resMsg
                        })
                    }
                },
                error => {
                    console.error('获取操作记录异常，异常信息：', error)
                }
            )
        },
        getPageList(pageNo = 1){
            this.pageNo = pageNo
            let queryOptRecordDto = {
                pageNo:pageNo,
                pageSize:this.pageSize,
                optId:this.optId,
                optModule:this.optModule
            }
            opt_record.getOptRecordList(queryOptRecordDto).then(
                response => {
                    console.log('操作记录响应数据：', response)
                    let resCode = response.data.code
                    let resMsg = response.data.message
                    if(resCode == "200") {
                        this.initData = response.data.data.data_list
                        this.pageNo = response.data.data.page_no
                        this.pageSize = response.data.data.page_size
                        this.total = response.data.data.total
                    } else {
                        //异常提示
                        this.$message({
                            type: 'error',
                            message: resMsg
                        })
                    }
                },
                error => {
                    console.error('获取操作记录异常，异常信息：', error)
                }
            )
        }
    },
    beforeMount(){
        console.log('开始初始化操作记录数据...')
        this.initOptRecordData()
    }
}
</script>

<style>

</style>